package fantasyfootball.data.entities;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * Class: 605.441 
 * Group: Richard Koretke, Kay Jantharasorn, Israel Rivera.
 * 
 * @author Israel Rivera
 * 
 */
@Entity(name="FantasyRoster")
public class FantasyRoster implements Serializable{

	private static final long serialVersionUID = 5974458375648310956L;
	
	private Integer rosterID;
	private FantasyTeam fantasyTeam;
	private NFLPlayer nflPlayer;
	private String position;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="RosterID", nullable=false)
	public Integer getRosterID() {
		return rosterID;
	}

	public void setRosterID(Integer rosterID) {
		this.rosterID = rosterID;
	}
	
	@JoinColumn(name="TeamName", nullable=false)
	@ManyToOne(fetch=FetchType.EAGER, optional=false)
	public FantasyTeam getFantasyTeam() {
		return fantasyTeam;
	}
	
	public void setFantasyTeam(FantasyTeam fantasyTeam) {
		this.fantasyTeam = fantasyTeam;
	}
	
	@JoinColumn(name="PlayerID", nullable=false)
	@ManyToOne(fetch=FetchType.EAGER, optional=false)
	public NFLPlayer getNflPlayer() {
		return nflPlayer;
	}
	
	public void setNflPlayer(NFLPlayer nflPlayer) {
		this.nflPlayer = nflPlayer;
	}
	
	@Column(name="Position", nullable=false)
	public String getPosition() {
		return position;
	}
	
	public void setPosition(String position) {
		this.position = position;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((rosterID == null) ? 0 : rosterID.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FantasyRoster other = (FantasyRoster) obj;
		if (rosterID == null) {
			if (other.rosterID != null)
				return false;
		} else if (!rosterID.equals(other.rosterID))
			return false;
		return true;
	}
}